#ProjectEuler-problem24:LexicographicPermutations

def is_big_to_small(li):
    big = li[0]
    for i in li[1:]:
        if i > big:
            return False
        big = i
    return True

def get_next_perm(permList):
    for i in permlist:
        if is_big_to_small(permList[permList.index(i):]):
            startDex = permList.index(i)
            break
    valDex = permList.index(permList[startDex-1])
    permList[valDex]=permList[startDex-1]
    permList[startDex-1]+=1
    newPerm=permList[:startDex]
    newPerm.extend(sorted(permList[startDex:])))
    return newPerm


